<?php
/**
 * Description of characterclass
 *
 * @author Machiel
 */
class Character {
    /**
     *
     * @var int
     */
    private $id;

    /**
     *
     * @var string
     */
    private $name;
    
    /**
     *
     * @var Inventory 
     */
    private $inventory;

    /**
     *
     * @var Location De locatie-klasse die bij deze character hoort
     */
    private $location;

    /**
     *
     * @var int Het id van de locatie waar deze character zich bevind
     */
    private $locationId;
    private $loadedLocation = false;

    function  __construct($id, $name, $locationid) {
        $this->id = $id;
        $this->name = $name;
        $this->locationId = $locationid;
    }

    public function getId() {
        return $this->id;
    }
    
    /**
     *
     * @return string
     */
    function getName(){
        return $this->name;
    }

    public function setName($name) {
        $this->name = $name;
    }

    /**
     *
     * @global Query $qm
     * @return Location
     */
    function getLocation() {
        if(!$this->loadedLocation) {
            global $qm;
            $this->loadedLocation = true;
            $this->location = $qm->getLocationFromCharacter($this);
        }

        return $this->location;
    }

    public function getLocationId() {
        return $this->locationId;
    }
}
?>
